package com.ecoolex.ying.space.ws;

import com.ecoolex.framework.common.exception.BizException;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import com.ecoolex.ying.space.core.manager.*;
import com.ecoolex.ying.space.entity.*;
import com.ecoolex.ying.space.pojo.*;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsBrandManager goodsBrandManager;
    @Autowired
    private GoodsClassifyManager goodsClassifyManager;
    @Autowired
    private GoodsLabelManager goodsLabelManager;
    @Autowired
    private GoodsManager goodsManager;
    @Autowired
    private GoodsAttachmentManager goodsAttachmentManager;
    @Autowired
    private GoodsSpecGroupManager goodsSpecGroupManager;
    @Autowired
    private GoodsSpecManager goodsSpecManager;
    @Autowired
    private GoodsProductManager goodsProductManager;
    @Autowired
    private GoodsLabelAssociateManager goodsLabelAssociateManager;

    @Override
    public GoodsBrand createBrand(GoodsBrand record, String createUser) throws BizException {
        return goodsBrandManager.create(record, createUser);
    }

    @Override
    public void updateBrand(GoodsBrand record, String updateUser) throws BizException {
        goodsBrandManager.update(record, updateUser);
    }

    @Override
    public void deleteBrand(GoodsBrand record, String updateUser) throws BizException {
        goodsBrandManager.delete(record, updateUser);
    }

    @Override
    public GoodsBrand getBrandById(Integer brandId) {
        return goodsBrandManager.getById(brandId);
    }

    @Override
    public List<GoodsBrand> queryAllBrand() {
        return goodsBrandManager.queryAll();
    }

    @Override
    public Pagination<GoodsBrand> queryBrand(QueryGoodsBrandDTO query, Sorting[] sorts, Page page) {
        return goodsBrandManager.query(query, sorts, page);
    }

    @Override
    public GoodsClassify createClassify(GoodsClassify record, String createUser) throws BizException {
        return goodsClassifyManager.create(record, createUser);
    }

    @Override
    public void updateClassify(GoodsClassify record, String updateUser) throws BizException {
        goodsClassifyManager.update(record, updateUser);
    }

    @Override
    public void deleteClassify(GoodsClassify record, String updateUser) throws BizException {
        goodsClassifyManager.delete(record, updateUser);
    }

    @Override
    public void showClassify(GoodsClassify record, String updateUser) throws BizException {
        goodsClassifyManager.show(record, updateUser);
    }

    @Override
    public void hideClassify(GoodsClassify record, String updateUser) throws BizException {
        goodsClassifyManager.hide(record, updateUser);
    }

    @Override
    public GoodsClassify getClassifyById(Integer classifyId) {
        return goodsClassifyManager.getById(classifyId);
    }

    @Override
    public List<GoodsClassify> queryAllClassify(Boolean isShow) {
        return goodsClassifyManager.queryAll(isShow);
    }

    @Override
    public List<GoodsClassify> queryAllParentClassify(Boolean isShow) {
        return goodsClassifyManager.queryAllParent(isShow);
    }

    @Override
    public List<GoodsClassify> queryClassifyByParentId(Integer parentClassifyId, Boolean isShow) {
        return goodsClassifyManager.queryByParentId(parentClassifyId, isShow);
    }

    @Override
    public Pagination<GoodsClassify> queryClassify(QueryGoodsClassifyDTO query, Sorting[] sorts, Page page) {
        return goodsClassifyManager.query(query, sorts, page);
    }

    @Override
    public Pagination<GoodsClassify> queryClassifyForH5(Integer parentClassifyId, Page page) {
        return goodsClassifyManager.queryClassifyForH5(parentClassifyId, page);
    }

    @Override
    public GoodsLabel createLabel(GoodsLabel record, String createUser) throws BizException {
        return goodsLabelManager.create(record, createUser);
    }

    @Override
    public void updateLabel(GoodsLabel record, String updateUser) throws BizException {
        goodsLabelManager.update(record, updateUser);
    }

    @Override
    public void deleteLabel(GoodsLabel record, String updateUser) throws BizException {
        goodsLabelManager.delete(record, updateUser);
    }

    @Override
    public GoodsLabel getLabelById(Integer labelId) {
        return goodsLabelManager.getById(labelId);
    }

    @Override
    public List<GoodsLabel> queryAllLabel() {
        return goodsLabelManager.queryAll();
    }

    @Override
    public List<GoodsLabel> queryLabel(QueryGoodsLabelDTO query, Integer maxSize) {
        return goodsLabelManager.query(query, maxSize);
    }

    @Override
    public Pagination<GoodsLabel> queryLabel(QueryGoodsLabelDTO query, Sorting[] sorts, Page page) {
        return goodsLabelManager.query(query, sorts, page);
    }

    @Override
    public List<GoodsLabel> queryLabelByGoodsId(Integer goodsId) {
        return goodsLabelManager.queryByGoodsId(goodsId);
    }

    @Override
    public List<GoodsLabel> queryLabelByPickGoodsId(Integer pickGoodsId) {
        return goodsLabelManager.queryByPickGoodsId(pickGoodsId);
    }

    @Override
    public long countGoodsByClassifyId(Integer classifyId) {
        return goodsManager.countByClassifyId(classifyId);
    }

    @Override
    public long countGoodsByBrandId(Integer brandId) {
        return goodsManager.countByBrandId(brandId);
    }

    @Override
    public long countGoodsByLabelId(Integer labelId) {
        return goodsLabelAssociateManager.countByLabelId(labelId);
    }

    @Override
    public GoodsWithBLOBs createGoods(EditGoodsDTO add, String createUser) throws BizException {
        return goodsManager.create(add, createUser);
    }

    @Override
    public void updateGoods(Integer goodsId, EditGoodsDTO edit, String updateUser) throws BizException {
        goodsManager.update(goodsId, edit, updateUser);
    }

    @Override
    public void deleteGoods(GoodsWithBLOBs record, String updateUser) throws BizException {
        goodsManager.delete(record, updateUser);
    }

    @Override
    public GoodsWithBLOBs getGoodsById(Integer goodsId) {
        return goodsManager.getById(goodsId);
    }

    @Override
    public Pagination<GoodsWithBLOBs> queryGoods(QueryGoodsDTO query, Sorting[] sorts, Page page) {
        return goodsManager.query(query, sorts, page);
    }

    @Override
    public void updateAttachment(Goods goods, EditGoodsAttachmentDTO[] edits, String updateUser) {
        goodsAttachmentManager.update(goods, edits, updateUser);
    }

    @Override
    public List<GoodsAttachment> queryAttachmentByGoodsId(Integer goodsId) {
        return goodsAttachmentManager.queryByGoodsId(goodsId);
    }

    @Override
    public GoodsAttachment getAttachmentById(Integer attachmentId) {
        return goodsAttachmentManager.getById(attachmentId);
    }

    @Override
    public void updateSpecGroup(Goods goods, final List<EditSpecGroupDTO> specGroup, String updateUser) {
        goodsSpecGroupManager.update(goods, specGroup, updateUser);
    }

    @Override
    public List<GoodsSpecGroup> querySpecGroupByGoodsId(Integer goodsId) {
        return goodsSpecGroupManager.queryByGoodsId(goodsId);
    }

    @Override
    public List<GoodsSpec> querySpecByGroupId(Integer groupId) {
        return goodsSpecManager.queryByGroupId(groupId);
    }

    @Override
    public GoodsProduct getProductById(Integer productId) {
        return goodsProductManager.getById(productId);
    }

    @Override
    public List<GoodsProduct> queryProductByGoodsId(Integer goodsId) {
        return goodsProductManager.queryByGoodsId(goodsId);
    }

    @Override
    public void updateProduct(EditGoodsProductDTO edit, String updateUser) {
        goodsProductManager.update(edit, updateUser);
    }

}
